//
//  Task_GetWsbsInfoDetail.m
//  EpointFrame5
//
//  Created by AndLi on 15/4/23.
//  Copyright (c) 2015年 Epoint. All rights reserved.
//  网上办事 信息详情

#import "Task_GetWsbsInfoDetail.h"

@implementation Task_GetWsbsInfoDetail
-(void)execute
{
    NSString *url           = NSLocalizedString(@"Epoint_DNet_WMH", @"");
    NSString *ValidateData  = [EpointBizTools getToken];
    NSString *namespace     = NSLocalizedString(@"Epoint_DNet_WMH_NameSpace", @"");
    
    NSString *infoid    = [params objectForKey:@"infoid"];
    NSString *isneedurl = [params objectForKey:@"isneedurl"];
    
    //请求接口
    NSString *method = @"GetWsbsInfoDetail";
    NSString *ParasXml = @"<![CDATA[<?xml version=\"1.0\" encoding=\"gb2312\"?><paras><infoid>%@</infoid><isneedurl>%@</isneedurl></paras>]]>";
    ParasXml = [NSString stringWithFormat:ParasXml,infoid,isneedurl];
    NSString *key = [NSString stringWithFormat:@"%@%@%@",method,infoid,isneedurl];
    
    //请求接口
    EpointWebServiceUtil *ws = [[EpointWebServiceUtil alloc]initWithUrl:url namespace:namespace method:method];
    [ws addParameterForString:@"ValidateData" value:ValidateData];
    [ws addParameterForString:@"ParasXml" value:ParasXml];
    NSString *bs =  ws.start;
    
    [self print:method withVali:ValidateData withXML:ParasXml withBs:bs];
    
    NSMutableArray *result = [self validateXMLWS2:bs];
    NSString *msg = [result objectAtIndex:1];
    if ([[result objectAtIndex:0]isEqualToString:@"1"]) {
        [DBFrameService setCacheValue:key value:bs];
        [self exeSuccessWithData:bs];
    }
    else
    {
        [self userCache:key message:msg];
    }
}
-(void)userCache:(NSString *)key message:(NSString *)msg
{
    //获取缓存数据
    NSString *cacheBS = [DBFrameService getCacheValue:key];
    //判断是否存在缓存
    if (cacheBS.length>0) {
        [self exeSuccessWithData:cacheBS];
    }
    else
    {
        [self exeFailureWithMessage:msg];
    }
}
@end
